package br.ufc.apsoo.repositories;

import java.io.Serializable;
import java.util.List;

import javax.persistence.EntityManager;

import org.hibernate.Criteria;
import org.hibernate.Session;
import org.hibernate.criterion.Order;

import br.com.caelum.vraptor.ioc.Component;
import br.ufc.apsoo.models.Pais;

@Component
public class PaisRepositoryImpl extends Repository<Pais, Serializable>
		implements TodosPaises {

	private final Session session;

	protected PaisRepositoryImpl(EntityManager entityManager) {
		super(entityManager);
		session = (Session) entityManager.getDelegate();
	}

	@Override
	public List<Pais> doMundo() {
		Criteria criteria = session.createCriteria(Pais.class).addOrder(Order.asc("id"));
		return criteria.list();
	}


}
